package com.hyzh.latte.hj.config;

import cn.hutool.core.collection.CollectionUtil;
import com.hyzh.latte.hj.dmo.entity.CommandEntity;
import com.hyzh.latte.hj.dmo.entity.SysCodeEntity;
import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author songkui
 * @since 2024/6/14 19:10
 */
@Getter
@Setter
public class ConfigManager {

    private final Map<Integer, SysCodeEntity> sysCodeMap = new HashMap<>();
    private final Map<Integer, CommandEntity> commandMap = new HashMap<>();


    private ConfigManager() {
    }

    private static final class ConfigManagerHolder {
        static final ConfigManager manager = new ConfigManager();
    }

    public static ConfigManager getInstance() {
        return ConfigManagerHolder.manager;
    }


    public void initSysCode(List<SysCodeEntity> list){
        if (CollectionUtil.isEmpty(list)){
            return;
        }

        for (SysCodeEntity entity : list){
            sysCodeMap.put(entity.getCode(), entity);
        }
    }

    public void initCommand(List<CommandEntity> list){
        if (CollectionUtil.isEmpty(list)){
            return;
        }

        for (CommandEntity entity : list){
            commandMap.put(entity.getCmCode(), entity);
        }
    }


}
